<?php
class alpha_api implements interface_platform {

	var $suid;
	var $uid;
	function init($type) {
		switch($type) {
			case '1': // 老用户
				$this->suid = mdl_account::getInstance()->getAccountSUIDByUID($_REQUEST['uid']);
				$this->uid = $_REQUEST['uid'];
				break;
			case '2': // 新用户
				$this->suid = time();
				break;
			default: // 意外用户
				die('who are u?');
		}
	}

	function init_inopt() {

	}

	function isNeedUpdate($uid) {
		return false;
	}

	function getUserPlatformId() {
		return $this->suid;
	}

	function getUserInfo($type) {
		switch($type) {
			case '1': // 老用户
				$x = mdl_field::getInstance()->getUserInfoByUID($this->uid);
				return new mdl_object_remoteuserinfo($this->suid, $x['name'], $x['nick'], $x['icon'], $x['sex']);
				break;
			case '2': // 新用户
				$name = $nick = $icon = $sex = '';
				$name = ( isset($_REQUEST['uname']) && !empty($_REQUEST['uname']) ) ? $_REQUEST['uname'] : 'user.' . date('Y-m-d H:i:s');
				return new mdl_object_remoteuserinfo($this->suid, $name, $nick, $icon, $sex);
				break;
			default: // 意外用户
				die('who are u?');
		}
	}

	function getUserContact() {
		return new mdl_object_remoteusercontact(array());
	}

	function getSession() {

	}

	function getGameUrl() {
		return urlencode('http://192.168.0.6:8888/__account/');
	}
}

return new alpha_api();